package com.bruce.service.impl;

import com.bruce.common.Response;
import com.bruce.dao.ResumeDao;
import com.bruce.dto.SearchDTO;
import com.bruce.po.ResumePO;
import com.bruce.service.ResumeService;
import com.bruce.util.IDUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author Liang.Yong.hui
 * @date 2021/7/3 22:37
 * @description
 */
@Service("resumeService")
public class ResumeServiceImpl implements ResumeService {
    @Resource
    private ResumeDao resumeDao;

    @Override
    public Response<Integer> add(ResumePO resumePO) {
        resumePO.setId(IDUtil.generateID(IDUtil.LEN_32));
        resumePO.setLastUpdTime(new Date());
        resumePO.setCreateTime(new Date());
        return new Response<>(resumeDao.add(resumePO));
    }

    @Override
    public Response<Integer> update(ResumePO resumePO) {
        resumePO.setLastUpdTime(new Date());
        return new Response<>(resumeDao.update(resumePO));
    }

    @Override
    public Response<List<ResumePO>> search(SearchDTO dto) {
        return new Response<>(resumeDao.search(dto));
    }

    @Override
    public Response<Integer> count() {
        return new Response<>(resumeDao.count());
    }

    @Override
    public Response<Integer> delete(String ids) {
        List<String> list = Arrays.asList(ids.split(","));
        return new Response<>(resumeDao.delete(list));
    }
}
